#include "Camera.h"

Camera::Camera()
{
	pitch = yaw = 0;
	//perspMat = glm::perspective<float>(45.0f, 4.0f / 3.0f, 0.1f, 100.0f);
	perspMat = glm::ortho<float>(-0.2f,0.2f,-0.15f, 0.15f, -500.0f, 500.0f);
	//perspMat = glm::frustum<float>(-0.5,0.5f,-0.5f, 0.5f, 0.001f, 500.0f);
	x = y = 0;
	zoom = 1.0f;

}

void Camera::setCameradX(float dx)
{
	x += dx;
	perspMat = glm::ortho<float>(zoom * (-0.2f) + x,zoom * 0.2f + x,zoom * (-0.15f) + y, zoom * 0.15f + y, -500.0f, 500.0f);
	
}

void Camera::setCameradY(float dy)
{
	y += dy;
	perspMat = glm::ortho<float>(zoom * (-0.2f) + x,zoom * 0.2f + x,zoom * (-0.15f) + y, zoom * 0.15f + y, -500.0f, 500.0f);
	
}

void Camera::setCameraZoomd(float scale)
{
	zoom += scale;
	perspMat = glm::ortho<float>(zoom * (-0.2f) + x,zoom * 0.2f + x,zoom * (-0.15f) + y, zoom * 0.15f + y, -500.0f, 500.0f);

}

glm::mat4& Camera::getViewMatrix()
{
	
	glm::mat4 upDown = glm::rotate<float>( glm::mat4(), pitch, glm::vec3( -1.0f, 0, 0) );//positive looks up, rotate clockwise around x-axis
	glm::mat4 leftRight = glm::rotate<float>( glm::mat4(), yaw, glm::vec3( 0, 1.0f, 0) );//positive looks up, rotate clockwise around x-axis
	glm::mat4 viewT = glm::translate<float>(glm::mat4(), -pos );//inverse camera position
	
	viewMat = upDown * leftRight * viewT;
	
	return  viewMat;
	
}

glm::mat4& Camera::getPerspMatrix()
{
	return perspMat;
}